<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form>


                    <p:panel header="Detailed Transfer Listing - (Consider after receiving)" >

                        <h:panelGrid columns="2" >
                            <h:outputLabel value="Transfer From" ></h:outputLabel>
                            <p:autoComplete completeMethod="#{departmentController.completeDept}" var="dept" 
                                            itemLabel="#{dept.name}" itemValue="#{dept}" forceSelection="true" 
                                            value="#{reportsTransfer.fromDepartment}" converter="departmentConverter" >
                            </p:autoComplete>
                            <h:outputLabel value="Transfer To" ></h:outputLabel>
                            <p:autoComplete completeMethod="#{departmentController.completeDept}" var="dept" 
                                            itemLabel="#{dept.name}" itemValue="#{dept}" forceSelection="true" 
                                            value="#{reportsTransfer.toDepartment}" converter="departmentConverter" >
                            </p:autoComplete>
                            <h:outputLabel value="From" ></h:outputLabel>
                            <p:calendar value="#{reportsTransfer.fromDate}" pattern="dd MM yyyy HH:mm:ss a" ></p:calendar>
                            <h:outputLabel value="To" ></h:outputLabel>
                            <p:calendar value="#{reportsTransfer.toDate}" pattern="dd MM yyyy HH:mm:ss a" ></p:calendar>
                        </h:panelGrid>

                        <h:panelGrid columns="3">
                            <p:commandButton ajax="false" value="Fill" action="#{reportsTransfer.fillDepartmentTransfersReceive()}" ></p:commandButton>
                            <p:commandButton value="Print" ajax="false" action="#" >
                                <p:printer target="gpBillPreview" ></p:printer>
                            </p:commandButton>

                            <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;" >
                                <pe:exporter type="xlsx" target="tbl" fileName="Detailed_Transfer_Listing"  />
                            </p:commandButton>
                        </h:panelGrid>

                        <h:panelGroup id="gpBillPreview">
                            <p:dataTable id="tbl" styleClass="noBorder normalFont"  
                                         value="#{reportsTransfer.transferItems}" var="i"  
                                         >

                                <f:facet name="header">
                                    <h:outputLabel value="Transfer List  From "/>
                                    <h:outputLabel value="#{reportsTransfer.fromDepartment.name}"/> 
                                    <h:panelGrid columns="4">
                                        <h:outputLabel value="From  "/>
                                        <h:outputLabel value="#{reportsTransfer.fromDate}">
                                            <f:convertDateTime pattern="dd/MM/yy &nbsp; hh:mm:ss a" ></f:convertDateTime>
                                        </h:outputLabel>
                                        <h:outputLabel value="To  "/>
                                        <h:outputLabel value="#{reportsTransfer.toDate}">
                                            <f:convertDateTime pattern="dd/MM/yy &nbsp; hh:mm:ss a" ></f:convertDateTime>
                                        </h:outputLabel>
                                    </h:panelGrid>
                                </f:facet>

                                <p:column headerText="Bill No"  
                                          sortBy="#{i.bill.deptId}"
                                          filterBy="#{i.bill.deptId}"
                                          filterMatchMode="contains"
                                          >
                                    <h:outputLabel value="#{i.bill.deptId}" ></h:outputLabel>
                                </p:column>
                                <p:column headerText="Ref. Bill No"
                                          >
                                    <h:outputLabel value="#{i.bill.backwardReferenceBill.deptId}" ></h:outputLabel>
                                </p:column>
                                <p:column headerText="Date"
                                          sortBy="#{i.bill.createdAt}"
                                          filterBy="#{i.bill.createdAt}"
                                          filterMatchMode="contains"
                                          >
                                    <h:outputLabel value="#{i.bill.createdAt}"  >
                                        <f:convertDateTime pattern="dd/MM/yy" ></f:convertDateTime>
                                    </h:outputLabel>
                                </p:column>
                                <p:column headerText="Item Descreption">
                                    <h:outputLabel value="#{i.item.name}"  >                                      
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Code"
                                          sortBy="#{i.pharmaceuticalBillItem.itemBatch.item.code}"
                                          filterBy="#{i.pharmaceuticalBillItem.itemBatch.item.code}"
                                          filterMatchMode="contains"
                                          >
                                    <f:facet name="header">
                                        <h:outputLabel value="Code"/>
                                    </f:facet>                           
                                    <h:outputLabel value="#{i.pharmaceuticalBillItem.itemBatch.item.code}" style="width: 100px!important;" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Qty" style="text-align: right;">
                                    <h:outputLabel value="#{i.pharmaceuticalBillItem.qty}"  >
                                        <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                    </h:outputLabel>
                                                                    </p:column>
                                <p:column headerText="Cost Rate" style="text-align: right;">
                                    <h:outputLabel value="#{i.pharmaceuticalBillItem.itemBatch.purcahseRate}"  >
                                        <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                    </h:outputLabel>                                  
                                </p:column>

                                <p:column headerText="Cost Value" style="text-align: right;">
                                    <h:outputLabel value="#{i.pharmaceuticalBillItem.itemBatch.purcahseRate * i.pharmaceuticalBillItem.qty}" >
                                        <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                    </h:outputLabel>                                  
                                </p:column>

                                <p:columnGroup type="footer">
                                    <p:row>
                                        <p:column colspan="6"/>
                                        <p:column style="text-align: right;" >
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{reportsTransfer.purchaseValue}" >
                                                    <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>                                        
                                    </p:row>
                                </p:columnGroup>

                            </p:dataTable>
                        </h:panelGroup>
                    </p:panel>
                </h:form>


            </ui:define>


        </ui:composition>

    </h:body>
</html>
